﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Data;

namespace iLangl
{
	public class BaseAlertDAL : IAlertDAL
	{
		public void SaveAlert(ISerializedAlert alert, IDbTransaction transaction)
		{
			ILog log = LogManager.GetLogger(alert.Source);

			String alertBody = alert.Content;

			Exception ex = new Exception(alertBody);
			switch (alert.Severity)
			{
				case eSeverity.Critical:
					log.Fatal(alertBody, ex);
					break;
				case eSeverity.High:
					log.Error(alertBody, ex );
					break;
				case eSeverity.Medium:
					log.Warn(alertBody, ex);
					break;
				case eSeverity.Low:
					log.Info(alertBody, ex);
					break;
				default:
					log.Debug(alertBody, ex);
					break;
			}

		}

		#region IAlertDAL Members

		public IList<ISerializedAlert> GetAlerts(TimeSpan from, TimeSpan to)
		{
			throw new NotImplementedException();
		}

		#endregion
	}
}
